package com.example.pmanagesys.controller;
// 账号管理
import com.example.pmanagesys.mapper.AccountManageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@RestController
@RequestMapping("/account")
public class AccountManageController {
    @Autowired
    private AccountManageMapper accountManageMapper;

    //  账号管理 页面
    @GetMapping("/file")
    public ModelAndView home() {
        return new ModelAndView("AccountManage");
    }

    //  启用  修改 http://localhost:8080/account/enable
    @PostMapping("/enable")
    public Integer enable( @RequestBody Map<String, Object> requestMap) {
        String update_time = (String) requestMap.get("update_time");
        int id = (int) requestMap.get("id");
        return accountManageMapper.enable(update_time,id);
    }

    //  禁用  修改 http://localhost:8080/account/disable
    @PostMapping("/disable")
    public Integer disable( @RequestBody Map<String, Object> requestMap) {
        String update_time = (String) requestMap.get("update_time");
        int id = (int) requestMap.get("id");
        return accountManageMapper.disable(update_time,id);
    }

    //  禁用  修改 http://localhost:8080/account/changepsw
    @PostMapping("/changepsw")
    public Integer changepsw( @RequestBody Map<String, Object> requestMap) {
        String password = (String) requestMap.get("password");
        String update_time = (String) requestMap.get("update_time");
        int id = (int) requestMap.get("id");
        return accountManageMapper.changepsw(password,update_time,id);
    }


}


